﻿/*
 * Crée par SharpDevelop.
 * Utilisateur: eldunkerquois
 * Date: 20/04/2011
 * Heure: 17:16
 * 
 * Pour changer ce modèle utiliser Outils | Options | Codage | Editer les en-têtes standards.
 */
using System;
using System.IO;
using openxml.butter.definition;

namespace OpenXmlBetterTest
{
	class Program
	{
		public static void Main(string[] args)
		{
			Console.WriteLine("Hello World!");
			
			
			
			DataTemplate dt = new DataTemplate("client2","Un client qui va à la fête, c'est bien" ) ;
			dt.AddItem( "nom","Nom du client" ,"De Gaulle" ) ;
			dt.AddItem( "prenom","Prénom du client" ,"Charles" ) ;
			dt.AddItem( "ville","Ville du client" ,"Dunkerque" ) ;
			dt.AddItem( "montant","montant effectif" ,"56.23" ) ;
			
			
			String path = @"c:\data\temp\toto.docx" ;			
			FileStream fs = new FileStream( path ,FileMode.Open );
			
			DocumentTemplate docT = new DocumentTemplate();
			
			docT.AddTemplate( dt ) ;
			docT.AssociateDataControl( "client.nom" , "client2", "nom") ;
			docT.AssociateDataControl( "client.ville" ,"client2","ville" ) ;
			docT.AssociateDataControl( "client.prenom" , "client2","prenom" ) ;
			docT.AssociateDataControl( "client.montant" , "client2","montant" ) ;
			
			docT.File = fs ;
			docT.setCustomParts() ;		
			
			
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
	}
}